package ${packageName}.app.configuration;

import android.app.Application;
import android.content.Context;

import com.alibaba.android.arouter.launcher.ARouter;
import ${packageName}.BuildConfig;
import com.jpxx.base.arouter.ARouterLog;
import com.jpxx.base.ui.mvp.base.delegate.AppLifecycles;
import com.jpxx.lib.klog.KLog;

import androidx.annotation.NonNull;
import butterknife.ButterKnife;

/**
 * ================================================
 * 展示 {@link AppLifecycles} 的用法
 * ================================================
 */
public class AppLifecyclesImpl implements AppLifecycles {

    @Override
    public void attachBaseContext(@NonNull Context base) {
//          MultiDex.install(base);  //这里比 onCreate 先执行,常用于 MultiDex 初始化,插件化框架的初始化
    }

    @Override
    public void onCreate(@NonNull Application application) {
         if (BuildConfig.DEV_MODE) {//Timber初始化
            ButterKnife.setDebug(true);
        }

        if(BuildConfig.DEV_MODE){
            KLog.setLogPriority(KLog.V);
        } else{
            KLog.setLogPriority(KLog.I);
        }
        KLog.init(BuildConfig.DEV_MODE, com.jpxx.base.BuildConfig.CBASE_LOG_TAG);

        if (BuildConfig.DEV_MODE) {           // 这两行必须写在init之前，否则这些配置在init过程中将无效
            ARouter.openLog();     // 打印日志
            ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行，必须开启调试模式！线上版本需要关闭,否则有安全风险)
            ARouter.setLogger(new ARouterLog());
        }

        // 全局异常拦截显示页面, 可自定义ErrorActivity UI
        //CustomActivityOnCrash.setErrorActivityClass(GlobalErrorCatchActivity.class);
        //CustomActivityOnCrash.install(application);

        //全局loading, retry, empty页面，可扩展更多状态
        //loading and retry layout
        //Gloading.debug(BuildConfig.DEV_MODE);
        //Gloading.initDefault(new GLoadingDefaultAdapter());
    }

    @Override
    public void onTerminate(@NonNull Application application) {

    }
}
